<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <div id="app">
      <!-- 1. .stop修饰符的使用，阻止事件冒泡 -->
      <div @click="divClick">
        aaaa
        <button @click.stop="btnClick">按钮</button>
      </div>

      <!-- 2. .prevent修饰符的使用，阻止默认行为 -->
      <br />
      <form action="baidu">
        <input type="submit" value="提交" @click.prevent="submitClick" />
      </form>

      <!-- 3. .监听的某个键 -->
      <input type="text" @keyup.enter="keyUp" />

      <!-- 4. .once修饰符的使用，只触发一次回调 -->
      <button @click.once="once">按钮</button>
    </div>

    <script src="../js/vue.js"></script>
    <script>
      const app = new Vue({
        el: '#app',
        data: {
          message: '你好'
        },
        methods: {
          divClick() {
            console.log('divClick')
          },
          btnClick() {
            console.log('btnClick')
          },
          submitClick() {
            console.log('submitClick')
          },
          keyUp() {
            console.log('keyUp')
          },
          once() {
            console.log('once')
          }
        }
      })
    </script>
  </body>
</html>
